<template>
	<!-- 我的订单页面 -->
	<view id="body">
		<!-- 切换按钮 -->
		<view class="top">
			<u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
		</view>
		<view class="contnt">
			<!-- 订单页面渲染 -->
			 <view id="order">
			 	<view class="order-card" v-for="(item,index) in orderList" :key="index">
			 		<view class="userimg">
			 			<u-avatar :src="item.img" size="100rpx"></u-avatar>
			 		</view>
			 		<text class="ordername">{{item.name}}</text>
			 		<text class="ordertitle">{{item.title}}</text>
			 		<text class="orderitem">{{item.item}}</text>
			 		<text class="ordertype">{{item.type}}</text>
					<text class="orderbutton" @click="fuclick(index)">立即付款</text>
			 		<text class="orderprice">{{item.price}}元</text>
					<view class="bottom">
						<u-divider text="我是有底线的"></u-divider>    
					</view>  
			 	</view>
			 </view> 
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				list: ['未付款','已付款','待评价',],
				current: 0,
				orderList:[
					{
						id:"1",
						img:"https://cdn.uviewui.com/uview/album/1.jpg",
						name:"管理员",
						title:"帮忙代取快递",
						type:"代取",
						price:8,
						item:"3KM",
					},
					{
						id:"2",
						img:"https://cdn.uviewui.com/uview/album/2.jpg",
						name:"洁白的小芳",
						title:"帮忙购买商品",
						type:"代购",
						price:8,
						item:"3KG",
					},
					{
						id:"3",
						img:"https://cdn.uviewui.com/uview/album/3.jpg",
						name:"把手给我",
						title:"帮忙代取快递",
						type:"代取",
						price:6,
						item:"2KG",
					},
					{
						id:"4",
						img:"https://cdn.uviewui.com/uview/album/4.jpg",
						name:"想念我的猫",
						title:"帮忙代取快递",
						type:"代取",
						price:12,
						item:"5KG",
					}
				]
			}
		},
		onShow() {
			//设置tabbar
			var str = uni.getStorageSync("tabbar")
			if(typeof str == 'string' && str.length > 0){
				var num = parseInt(str)
				if(num > 0){
					uni.setTabBarBadge({ //显示数字
						index: 1, //tabbar下标
						text:""+num,//数字
						success() {
						console.log("设置成功") 
						},
						fail(e){ 
						   console.log("设置失败"+JSON.stringify(e))
						}
					})
					uni.setStorageSync("tabbar",JSON.stringify(num))
					this.$forceUpdate()
				}
			}
		},
		methods: {
			sectionChange(index) {
				this.current = index;
				console.log("点击的是:"+index)
			},
			fuclick(index){
				console.log("点击的按钮是："+index)
			},
		}
	
	}
</script>

<style>
	@import url("@/static/css/myorder.css");
</style>